<template>
  <el-menu
    active-text-color="#ffd04b"
    background-color="#409eff"
    class="aside-container"
    default-active="2"
    text-color="#fff"
    @open="handleOpen"
    @close="handleClose"
    :collapse="isCollapse"
    :style="{ width: !isCollapse ? '180px' : '64px' }"
  >
    <p class="logo-lp">{{ isCollapse ? '图片' : '果园管理系统' }}</p>
    <TreeMenu :menuData="menuData" />
  </el-menu>
</template>

<script setup>
import TreeMenu from './treeMenu.vue';
import { reactive, computed } from 'vue';
import { useStore } from 'vuex';
import { useRouter } from 'vue-router';

const store = useStore();
const router = useRouter();

const isCollapse = computed(() => store.state.menu.isCollapse);

const menuData = reactive([
  {
    path: '/dashboard',
    meta: {
      id: '1',
      name: '控制台',
      icon: 'House',
      path: '/dashboard',
      describe: '用于展示当前系统中统计的数据、统计报表及重要的实时数据'
    },
    component: () => import('../view/adshboard/index.vue')
  },
  {
    path: '/dashboard/auth',
    meta: { id: '2', name: '人工智能', icon: 'Grid' },
    children: [
      {
        path: 'admin',
        meta: {
          id: '1',
          name: '通义千问',
          icon: 'Avatar',
          path: '/dashboard/auth/admin',
          describe: '管理员可以进行编辑，权限修改过后需要登出才会生效'
        },
        component: () => import('../view/auth/admin/index.vue')
      },
      {
        path: 'group',
        meta: {
          id: '2',
          name: 'DeepSeek',
          icon: 'Menu',
          path: '/dashboard/auth/group',
          describe: '管理员可以进行编辑，权限修改过后需要登出才会生效'
        },
        component: () => import('../view/auth/group/index.vue')
      }
    ]
  },
  {
    path: '/dashboard/function',
    meta: { id: '3', name: '图片分析', icon: 'Platform' },
    children: [
      {
        path: 'order',
        meta: {
          id: '1',
          name: '实时监控',
          icon: 'PieChart',
          path: '/dashboard/function/order',
          describe: '管理员可以进行编辑，权限修改过后需要登出才会生效'
        },
        component: () => import('../view/function/order/index.vue')
      },
      {
        path: 'staff',
        meta: {
          id: '2',
          name: '监控预警',
          icon: 'FullScreen',
          path: '/dashboard/function/staff',
          describe: '管理员可以进行编辑，权限修改过后需要登出才会生效'
        },
        component: () => import('../view/function/staff/index.vue')
      }
    ]
  }
]);

const handleOpen = () => {};
const handleClose = () => {};
</script>

<style lang="less">
.logo-lp {
  font-size: 20px;
  text-align: center;
  height: 50px;
  line-height: 50px;
  color: #fff;
}

.aside-container {
  height: 100%;
  overflow-y: auto;
}

.el-menu {
  border-right: none;
  background-color: aliceblue;
}

.el-menu-item,
.el-sub-menu__title {
  height: 56px;
  line-height: 56px;
}
</style>